﻿using System;
using System.Windows.Forms;

namespace CXW.Core.Sharp
{
    /// <summary>语言切换窗体</summary>
    public partial class UILanguageForm : BaseForm
    {
        /// <summary></summary>
        public UILanguageForm()
        {
            InitializeComponent();

            gridControl1.DataSource = LanguageService.Languages;

            Language = "Form.UILanguage";

            OnLanguageChanged();

            this.winExplorerView1.FocusedRowHandle = LanguageService.GetLanguageIndex(ResourceService.Language);
        }
        public override void OnLanguageChanged()
        {
            base.OnLanguageChanged();
            btnOK.Text = ResourceService.GetString(btnOK.AccessibleDescription);
            btnCANCEL.Text = ResourceService.GetString(btnCANCEL.AccessibleDescription);
        }
        private void btnOK_Click(object sender, EventArgs e)
        {
            string language = "";
            if ((language = ((Language)this.winExplorerView1.GetFocusedRow()).Code) != ResourceService.Language)
            {
                ResourceService.Language = language;
                PropertyService.Save();
            }
            this.DialogResult = DialogResult.OK;
        }

        private void btnCANCEL_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}